<?php
namespace app\validate;

use think\Validate;

class UserValidate extends Validate
{
    // 定义验证规则
    protected $rule = [
        'mobile' => 'require|mobile',
        'check_code' => 'require|max:6',
        'avatar' => 'require',
        'nickname' => 'require|max:10',
    ];


    // 定义提示信息
    protected $message = [
        'mobile.require' => '手机号不能为空',
        'mobile.mobile' => '手机号格式错误',
        'sms_code.require' => '验证码不能为空',
        'sms_code.max' => '验证码格式错误',
        'avatar.require' => '请上传头像',
        'nickname.require' => '请填写昵称',
        'nickname.max' => '昵称最多10个字符',
    ];

    // 定义验证场景
    protected $scene = [
        'register' => ['mobile', 'check_code'],
        'login' => ['mobile', 'check_code'],
        'editUserInfo' => ['avatar', 'nickname', 'mobile'],
    ];
}
